#include <iostream>

using namespace std;

class Rational {
private:
	int num;
	int den;

	void normalize() {
		int g = gcd(num, den);
		num /= g;
		den /= g;
	}
		
	int gcd(int v1, int v2) {
		if(v1 == 0 || v2 == 0) {
			return 1;
		} else if (v1 < v2) {
			return gcd (v2 % v1, v1);
		} else {
			return gcd (v1 % v2, v2);
		}
	}

public:
	Rational(const int num, const int den) : num(num) , den (den) {
		normalize();
	}

	Rational(const int num) : num(num), den(0) {
	}

	Rational(const Rational & rational){
		this->num = rational.num;
		this->den = rational.den;
	}

	~Rational() {
	}

	Rational& operator= (const Rational& r); 
    Rational& operator+= (const Rational& r); 
    Rational& operator-= (const Rational& r); 
    Rational& operator*= (const Rational& r); 
    Rational& operator/= (const Rational& r); 
    Rational& operator++();
    Rational operator++(int);
    Rational& operator--();
    Rational operator--(int);

    operator double ();

	friend ostream & operator<<(ostream &out, const Rational & a);

	friend Rational operator+ (const Rational& a, const Rational& b);
	friend Rational operator- (const Rational& a, const Rational& b);
	friend Rational operator* (const Rational& a, const Rational& b);
	friend Rational operator/ (const Rational& a, const Rational& b);

	friend bool operator== (const Rational& a, const Rational& b);
	friend bool operator!= (const Rational& a, const Rational& b);
	friend bool operator<= (const Rational& a, const Rational& b);
	friend bool operator>= (const Rational& a, const Rational& b);
	friend bool operator<  (const Rational& a, const Rational& b);
	friend bool operator>  (const Rational& a, const Rational& b);

	

};

